package com.samson.controller;

import com.samson.domain.Item;
import com.samson.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/item")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @RequestMapping("/showDetail")
    public ModelAndView showDetail() {
        Item item = itemService.findById(1);
        ModelAndView mv = new ModelAndView();
        mv.addObject("item", item);
        //设置逻辑视图名，视图解析器会根据该名字解析到具体的视图页面
        mv.setViewName("itemDetail");//通过setViewName()方法跳转到指定的页面
        return mv;
    }
}
